package tables

import (
	"github.com/GoAdminGroup/go-admin/context"
	"github.com/GoAdminGroup/go-admin/modules/db"
	"github.com/GoAdminGroup/go-admin/plugins/admin/modules/table"
	"github.com/GoAdminGroup/go-admin/template/types"
	"github.com/GoAdminGroup/go-admin/template/types/form"
)

// GetBrandMiniApp return the model of table brand_mini_app.
func GetBrandMiniApp(ctx *context.Context) (stTable table.Table) {

	config := table.DefaultConfigWithDriver("postgresql")

	stTable = table.NewDefaultTable(config)

	info := stTable.GetInfo()
	info.AddField("ID", "id", db.Int)
	info.AddField("应用ID", "app_id", db.Varchar)
	info.AddField("平台", "platform", db.Int).FieldDisplay(func(value types.FieldModel) interface{} {
		switch value.Row["platform"].(int64) {
		case 1:
			return "微信"
		case 2:
			return "支付宝"
		case 3:
			return "字节跳动"
		default:
			return "未知状态"
		}
	})
	info.AddField("品牌ID", "brand_id", db.Int)
	info.AddField("操作员工", "emp_id", db.Int)

	info.SetTable("brand_mini_app").SetTitle("品牌小程序信息").SetDescription("品牌小程序信息")

	formList := stTable.GetForm()
	formList.AddField("ID", "id", db.Int, form.Text)
	formList.AddField("应用ID", "app_id", db.Varchar, form.Text)
	formList.AddField("平台", "name", db.Int, form.Text)
	formList.AddField("品牌ID", "icon", db.Int, form.Text)
	formList.AddField("操作员工", "qr_code_url", db.Int, form.Text)

	formList.SetTable("brand_mini_app").SetTitle("品牌小程序信息").SetDescription("品牌小程序信息")
	return
}
